ember-cli / ember-compatibility-helpers

Helpers that allow you to write backwards compat Ember addons
MIT License
24 stars 20 forks source link

feat(build): generate TypeScript declaration file #31

Closed buschtoens closed 5 years ago

buschtoens commented 5 years ago

This PR extracts the flags definitions for the debug plugin into a separate file, so that a TypeScript declaration file can be generated from them in the prepack step, that is executed right before the addon is published to npm.

buschtoens commented 5 years ago

The generated index.d.ts looks like this:

export function gte(version: string): boolean;
export function lte(version: string): boolean;
export const HAS_UNDERSCORE_ACTIONS: boolean;
export const HAS_MODERN_FACTORY_INJECTIONS: boolean;
export const HAS_DESCRIPTOR_TRAP: boolean;
export const HAS_NATIVE_COMPUTED_GETTERS: boolean;
export const IS_GLIMMER_2: boolean;
export const IS_RECORD_DATA: boolean;
export const SUPPORTS_FACTORY_FOR: boolean;
export const SUPPORTS_GET_OWNER: boolean;
export const SUPPORTS_SET_OWNER: boolean;
export const SUPPORTS_NEW_COMPUTED: boolean;
export const SUPPORTS_INVERSE_BLOCK: boolean;
export const SUPPORTS_CLOSURE_ACTIONS: boolean;
export const SUPPORTS_UNIQ_BY_COMPUTED: boolean;
pzuraq commented 5 years ago

Should the generated types be included? Or is that done only on publish?

buschtoens commented 5 years ago

I've added /index.d.ts to the .gitignore to avoid having out of date / mismatching types in the repo, that would get overridden during publishing, because someone forgot to run a script. 😄