Before You Start
I think this design proposal aligns with TypeScript Design Goals and helps TypeScript authors to write more efficient packages (and help the JavaScript ecosystem in general this way).
The are very similar existing suggestions, but it looks like none of them leverages side-effects: false in package.json directly.
E.g. there is
Defining a Scenario
As a lib author I'd like to create packages which are easy to consume by tools and allow features like efficient tree shaking. I'd like to re-use existing conventions to flag my package with a certain feature (in this case side-effects: false in package.json). I'd like TypeScript to assist me in writing packages which fulfil this constraint.
So basically:
- When I write a TypeScript-based package...
- ...and set
side-effects: false in package.json...
- ...I want the TypeScript compiler to throw errors, when I invalidate this constraint.
Language Feature Checklist
This change should be able to be introduced without a breaking change and should keep backwards compatibility with the JS language.
Side effects free packages
See here for an example.
cc @TheLarkInn
Before You Start
I think this design proposal aligns with TypeScript Design Goals and helps TypeScript authors to write more efficient packages (and help the JavaScript ecosystem in general this way).
The are very similar existing suggestions, but it looks like none of them leverages
side-effects: falsein package.json directly.E.g. there is
Defining a Scenario
As a lib author I'd like to create packages which are easy to consume by tools and allow features like efficient tree shaking. I'd like to re-use existing conventions to flag my package with a certain feature (in this case
side-effects: falsein package.json). I'd like TypeScript to assist me in writing packages which fulfil this constraint.So basically:
side-effects: falsein package.json...Language Feature Checklist
This change should be able to be introduced without a breaking change and should keep backwards compatibility with the JS language.
Side effects free packages
See here for an example.
cc @TheLarkInn