Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build node API due to typescript issues #1001

Closed
prabir-vora opened this issue Jul 6, 2022 · 6 comments
Closed

Cannot build node API due to typescript issues #1001

prabir-vora opened this issue Jul 6, 2022 · 6 comments

Comments

@prabir-vora
Copy link

prabir-vora commented Jul 6, 2022

My node API compilation fails while building using tsc. Getting 29 type errors in types.d.ts.

As mentioned in #834 and #841 I tried adding the "skipLibCheck": true and "lib": ["DOM"] flag to my tsconfig.json. I additionally event tried adding --skipLibCheck flag to my build command. However, the type files from stream-chat are not getting ignored.

Here is what my tsconfig.json looks like

{
    "compilerOptions": {
        "target": "es2018",
        "module": "commonjs",
        "lib": ["es2015", "es2018", "esnext.asynciterable", "DOM"],
        "skipLibCheck": true,
        "sourceMap": true,
        "outDir": "build",
        "rootDir": "./",
        "strictFunctionTypes": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "noUnusedLocals": false,
        "noUnusedParameters": false,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "baseUrl": "./src",
        "paths": {
            "*": ["typings/*"],
            "@app/*": ["app/*"],
            "@service/*": ["services/*"],
            "@model/*": ["models/*"],
            "@helper/*": ["helpers/*"],
            "@module/*": ["modules/*"],
            "@library/*": ["lib/*"],
            "@config/*": ["configs/*"]
        },
        "types": ["mocha", "node"],
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "allowSyntheticDefaultImports": true,
        "resolveJsonModule": true
    },
    "exclude": ["**/dist", "**/node_modules", "**/*.spec.ts", "**/__tests__", "build", "bin", "node_modules"]
}

My build command is inside package.json is

"build": "tsc --skipLibCheck --project . --outDir ./bin",

@vanGalilea
Copy link
Contributor

@prabir-vora thanks for reaching out, what version of typescript are you using?

@prabir-vora
Copy link
Author

@prabir-vora thanks for reaching out, what version of typescript are you using?

@vanGalilea Earlier I was using version 3 but it didn't work. So I upgraded to the latest version 4.7.4 but no luck.

@santhoshvai
Copy link
Member

santhoshvai commented Jul 6, 2022

@prabir-vora can you post the type errors that you get after upgrading to latest TS version please

@prabir-vora
Copy link
Author

node_modules/stream-chat/dist/types/types.d.ts:411:37 - error TS1005: '>' expected.

411 i18n?: RequireAtLeastOne<Record<${TranslationLanguages}_text, string>> & {
~~~

node_modules/stream-chat/dist/types/types.d.ts:411:78 - error TS1109: Expression expected.

411 i18n?: RequireAtLeastOne<Record<${TranslationLanguages}_text, string>> & {
~

node_modules/stream-chat/dist/types/types.d.ts:412:39 - error TS1005: ',' expected.

412 language: TranslationLanguages;
~

node_modules/stream-chat/dist/types/types.d.ts:414:22 - error TS1109: Expression expected.

414 latest_reactions?: ReactionResponse[];
~

node_modules/stream-chat/dist/types/types.d.ts:415:21 - error TS1109: Expression expected.

415 mentioned_users?: UserResponse[];
~

node_modules/stream-chat/dist/types/types.d.ts:416:19 - error TS1109: Expression expected.

416 own_reactions?: ReactionResponse[] | null;
~

node_modules/stream-chat/dist/types/types.d.ts:417:17 - error TS1109: Expression expected.

417 pin_expires?: string | null;
~

node_modules/stream-chat/dist/types/types.d.ts:418:15 - error TS1109: Expression expected.

418 pinned_at?: string | null;
~

node_modules/stream-chat/dist/types/types.d.ts:419:15 - error TS1109: Expression expected.

419 pinned_by?: UserResponse | null;
~

node_modules/stream-chat/dist/types/types.d.ts:419:50 - error TS1005: '(' expected.

419 pinned_by?: UserResponse | null;
~

node_modules/stream-chat/dist/types/types.d.ts:419:56 - error TS1005: ')' expected.

419 pinned_by?: UserResponse | null;
~

node_modules/stream-chat/dist/types/types.d.ts:420:21 - error TS1109: Expression expected.

420 reaction_counts?: {
~

node_modules/stream-chat/dist/types/types.d.ts:421:13 - error TS1005: ']' expected.

421 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:421:21 - error TS1005: ',' expected.

421 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:421:22 - error TS1136: Property assignment expected.

421 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:421:30 - error TS1005: ',' expected.

421 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:423:21 - error TS1109: Expression expected.

423 reaction_scores?: {
~

node_modules/stream-chat/dist/types/types.d.ts:424:13 - error TS1005: ']' expected.

424 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:424:21 - error TS1005: ',' expected.

424 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:424:22 - error TS1136: Property assignment expected.

424 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:424:30 - error TS1005: ',' expected.

424 [key: string]: number;
~

node_modules/stream-chat/dist/types/types.d.ts:426:17 - error TS1109: Expression expected.

426 reply_count?: number;
~

node_modules/stream-chat/dist/types/types.d.ts:427:14 - error TS1109: Expression expected.

427 shadowed?: boolean;
~

node_modules/stream-chat/dist/types/types.d.ts:428:12 - error TS1109: Expression expected.

428 silent?: boolean;
~

node_modules/stream-chat/dist/types/types.d.ts:429:12 - error TS1109: Expression expected.

429 status?: string;
~

node_modules/stream-chat/dist/types/types.d.ts:430:25 - error TS1109: Expression expected.

430 thread_participants?: UserResponse[];
~

node_modules/stream-chat/dist/types/types.d.ts:431:10 - error TS1109: Expression expected.

431 type?: MessageLabel;
~

node_modules/stream-chat/dist/types/types.d.ts:432:16 - error TS1109: Expression expected.

432 updated_at?: string;
~

node_modules/stream-chat/dist/types/types.d.ts:433:1 - error TS1128: Declaration or statement expected.

433 };
~

Found 29 errors.

@santhoshvai
Copy link
Member

Hey @prabir-vora, I created a test project. I can find the same 29 errors if I am on typescript v3.9, but not on typescript v4.7.4. Please make sure that you have properly reinstalled typescript. After changing the package.json, run npm install or yarn again. And then run your build command again.

@jrista
Copy link

jrista commented Jul 26, 2023

I believe the issue is because of TypeScript strict mode. Strict mode enforces much more stringent typing requirements. This is now default in Angular since version 14, and strict mode provides a lot of value as it brings to the surface many issues at compile time that would otherwise blow up an app at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants