Comments (7)
I found a different workaround for this. TypeScript 3.1.1 fixes microsoft/TypeScript#26497, which means it now preserves directives. So the workaround is to duplicate the tslint config lib property as directives. Annoying to have to duplicate this, but at least it fixes the problem for now.
from is.
We have lib.es2017.sharedmemory
in our config, but I didn't think that would be required for consumers too. It's weird that TS handles it like this, unless I'm missing something.
@SamVerschueren Any ideas?
from is.
You can set skipLibCheck
to false
. See https://www.typescriptlang.org/docs/handbook/compiler-options.html. By default, TS checks all shipped type definitions in node_modules as well. But I agree that it's weird for consumers to care about this. Will dive deeper into it when I have some more time.
from is.
On the other hand, if you want to use the type definitions, you as a consumer also needs to know what SharedArrayBuffer is. So the error might make sense.
from is.
This boils down to the fact that the TypeScript compiler does not attempt to remove references to SharedArrayBuffer
even when the compiler target set to es2016
. For example const foo = new SharedArrayBuffer(4);
compiles to const foo = new SharedArrayBuffer(4);
. So strictly speaking, when your lib
includes lib.es2017.sharedmemory
and your target
is set to es2016
, the actual target JavaScript environment should be thought of as "es2016 + a SharedArrayBuffer polyfill". By the same token on the TypeScript side, the consumer's lib
must include lib.es2017.sharedmemory
.
Now specifically in the case of this project it just so happens that the .js
output does NOT include any references to SharedArrayBuffer
. So while in theory this project's compiler setup would require SharedArrayBuffer
to be present in the target execution environment, in actuality it does not. No such luck on the TypeScript side. The .d.ts
files most definitely have references to the global type SharedArrayBuffer
and the consumer must include lib.es2017.sharedmemory
if they want to use this.
I can think of a couple ways to close this issue:
-
(My preference): Remove
SharedArrayBuffer
as one of the things that this library knows how to type check. Of course this change would not be backwards compatible. Perhaps that feature could be split off into its own package. -
Add a short note of documentation to the README explaining that if you're using TypeScript this package requires
lib.es2017.sharedmemory
.
If folks 👍 one or the other of these approaches I'd be happy to take a stab at the "fix".
from is.
(My preference): Remove SharedArrayBuffer as one of the things that this library knows how to type check. Of course this change would not be backwards compatible. Perhaps that feature could be split off into its own package.
I'm ok with this. I don't think many would use this check yet anyway. We can reintroduce it some time in the future.
@carnesen Would you be able to open an issue on the TypeScript issue tracker about this? There really should be a way for a library to include lib.es2017.sharedmemory
without the consumer having to care about it. Maybe some kind of directive comment.
from is.
TypeScript issue: microsoft/TypeScript#27416
from is.
Related Issues (20)
- Property 'function' does not exist on type 'typeof is'. HOT 1
- Proposal: is.nonEmptyStringAndNotWhitespace(value) HOT 10
- [v5] Better handling of `NaN`
- test code perf HOT 1
- Can't access default export properties when `moduleResolution: 'NodeNext'` HOT 3
- Add is.renderInReact or is.notRenderInReact HOT 1
- Question: What is the reason Node.js below version 14.16 is not supported? HOT 2
- add type inference to "nonEmptyArray"
- Confused between class_ docs and implementation HOT 1
- How to shorten: `"prop" in obj && obj.prop`
- Improve type narrowing for `nonEmptyArray` HOT 1
- is.numericString type guarding returns `x is string` and messes up typescript HOT 4
- Parcel JS build issue - No Main HOT 1
- v5.4.0 "Cannot find module '@sindresorhus/is' or its corresponding type declarations" HOT 4
- `plainObject` is incompatible with `structuredClone` HOT 2
- Some type guards under assert are not working HOT 1
- directInstanceOf(instance, class) throws error if instance is null or undefined HOT 1
- Struggling to configure jest to compile `is` HOT 1
- is.enumCase method is not a type guard HOT 2
- Typing errors with the isEmptyStringOrWhitespace type guard HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from is.