Popper-core: Unable to compile with typescript 2.4.2 and "strictNullChecks": true,

Created on 5 Sep 2017  路  10Comments  路  Source: popperjs/popper-core

Hello,

I'm using popper.js with typescript (being imported from @blueprintjs/labs node module) and when I have "strictNullChecks": true, I get the error below. If I change my setting to "strictNullChecks": false, then everything compiles. Let me know if I should report this to blueprintjs but figured I would start here for now. @giladgray might know what's up. I did a full rm -rf node_modules and yarn install before seeing this error.

yarn build v0.27.5
$ react-scripts-ts build
Creating an optimized production build...
ts-loader: Using [email protected] and /Users/dennison/projects/echelon/echelon-web/tsconfig.json
Failed to compile.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(38,5): error TS2411: Property 'shift' of type 'BaseModifier | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(39,5): error TS2411: Property 'offset' of type '(BaseModifier & { offset?: string | number | undefined; }) | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(42,5): error TS2411: Property 'preventOverflow' of type '(BaseModifier & { priority?: ("bottom" | "top" | "left" | "right")[] | undefined; padding?: numbe...' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(47,5): error TS2411: Property 'keepTogether' of type 'BaseModifier | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(48,5): error TS2411: Property 'arrow' of type '(BaseModifier & { element?: string | Element | undefined; }) | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(51,5): error TS2411: Property 'flip' of type '(BaseModifier & { behavior?: ("bottom" | "top" | "left" | "right")[] | "flip" | "clockwise" | "co...' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(56,5): error TS2411: Property 'inner' of type 'BaseModifier | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(57,5): error TS2411: Property 'hide' of type 'BaseModifier | undefined' is not assignable to string index type 'BaseModifier & Record<string, any>'.

/Users/dennison/projects/echelon/echelon-web/node_modules/popper.js/index.d.ts
(58,5): error TS2411: Property 'applyStyle' of type '(BaseModifier & { onLoad?: Function | undefined; gpuAcceleration?: boolean | undefined; }) | unde...' is not assignable to string index type 'BaseModifier & Record<string, any>'.

Most helpful comment

Thanks @MrFrankel "skipLibCheck": true, did the trick. TIL

All 10 comments

I don't have experience with TypeScript, the types are (or should?) be maintained by @giladgray and @edcarroll but since both seem to haven't time to work on it I think I'll simply get rid of them because they seem just plain broken...

@DrewDennison you should probably add to your tsconfig.js :
"skipDefaultLibCheck": true, "skipLibCheck": true, "exclude": [ "node_modules" ]

TS errors in node_modules shouldn't effect your build.

Don't you lose any type information from node_modules doing so?

Please keep the types! @FezVrasta I'm happy to help with maintaining them and will submit PRs if that's helpful.

Yup PRs are always welcome, if you manage to fix this without breaking backward compatibility I'm happy to merge it.

@FezVrasta, no, it will simply not check them for internal errors, obviously libraries that support types should not have errors in them, but as consumers we cant have our build's fail due to a TS error

Thanks @MrFrankel "skipLibCheck": true, did the trick. TIL

So.. Is a fix still needed?

Not for me

Used nuget to Install popper.js 1.12.5 and bootstrap v4 beta into Visual Studio 2015 v3. Get build error in index.d.ts that "Record" type is not defined. Currently have TypeScript v1.8 installed. Does popper.js 1.12.5 require a new version of TypeScript?

Was this page helpful?
0 / 5 - 0 ratings