mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
feat: add typings for Buble (#32515)
* chore(buble): setup * feat(buble): implement tons of options and tests * feat(buble): export interfaces, this can be useful * feat(buble): add "includeContent" option * fix(buble): add "dom" lib, fix sourcemap and linting issues
This commit is contained in:
committed by
Pranav Senthilnathan
parent
29eb368cdd
commit
2a76edab65
77
types/buble/buble-tests.ts
Normal file
77
types/buble/buble-tests.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import * as buble from 'buble';
|
||||
|
||||
const input = 'const answer = () => 42;';
|
||||
|
||||
// Simple transform
|
||||
(() => {
|
||||
const output = buble.transform(input);
|
||||
|
||||
console.log(output.code);
|
||||
console.log(output.map.toString());
|
||||
console.log(output.map.toUrl);
|
||||
})();
|
||||
|
||||
// Transform for Chrome & Firefox
|
||||
(() => {
|
||||
const output = buble.transform(input, {
|
||||
target: {
|
||||
chrome: 71,
|
||||
firefox: 64,
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
// Transform with sourcemaps support
|
||||
(() => {
|
||||
const output = buble.transform(input, {
|
||||
source: 'input.js',
|
||||
file: 'output.js',
|
||||
includeContent: true,
|
||||
});
|
||||
})();
|
||||
|
||||
// Transform for Preact
|
||||
(() => {
|
||||
const output = buble.transform(input, {
|
||||
jsx: 'h'
|
||||
});
|
||||
})();
|
||||
|
||||
// Transform with Object assign/spread support
|
||||
(() => {
|
||||
let output = buble.transform(input, {
|
||||
objectAssign: true,
|
||||
});
|
||||
output = buble.transform(input, {
|
||||
objectAssign: 'MyCustomObjectAssign',
|
||||
});
|
||||
})();
|
||||
|
||||
// Transform with every transforms
|
||||
(() => {
|
||||
const output = buble.transform(input, {
|
||||
transforms: {
|
||||
arrow: true,
|
||||
classes: false,
|
||||
collections: true,
|
||||
computedProperty: false,
|
||||
conciseMethodProperty: true,
|
||||
constLoop: false,
|
||||
dangerousForOf: true,
|
||||
dangerousTaggedTemplateString: false,
|
||||
defaultParameter: true,
|
||||
destructuring: false,
|
||||
forOf: true,
|
||||
generator: false,
|
||||
letConst: true,
|
||||
modules: false,
|
||||
numericLiteral: true,
|
||||
parameterDestructuring: false,
|
||||
reservedProperties: true,
|
||||
spreadRest: false,
|
||||
stickyRegExp: true,
|
||||
templateString: false,
|
||||
unicodeRegExp: true,
|
||||
}
|
||||
});
|
||||
})();
|
||||
65
types/buble/index.d.ts
vendored
Normal file
65
types/buble/index.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// Type definitions for buble 0.19
|
||||
// Project: https://github.com/Rich-Harris/buble#README
|
||||
// Definitions by: Kocal <https://github.com/Kocal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface TransformOptions {
|
||||
// source: https://github.com/Rich-Harris/buble/blob/master/src/support.js
|
||||
target?: {
|
||||
chrome?: 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71;
|
||||
firefox?: 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64;
|
||||
safari?: 8 | 9 | 10 | 10.1 | 11 | 11.1 | 12;
|
||||
ie?: 8 | 9 | 10 | 11;
|
||||
edge?: 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19;
|
||||
node?: 0.10 | 0.12 | 4 | 5 | 6 | 8 | 8.3 | 8.7 | 8.10;
|
||||
};
|
||||
|
||||
// used for sourcemaps
|
||||
source?: string; // input
|
||||
file?: string; // output
|
||||
includeContent?: boolean;
|
||||
|
||||
// custom JSX pragma (https://buble.surge.sh/guide/#jsx)
|
||||
jsx?: string; // default: 'React.createElement'
|
||||
|
||||
// custom `Object.assign` (https://buble.surge.sh/guide/#object-spread-and-rest)
|
||||
objectAssign?: string | boolean;
|
||||
|
||||
// transforms
|
||||
transforms?: {
|
||||
arrow?: boolean;
|
||||
classes?: boolean;
|
||||
collections?: boolean;
|
||||
computedProperty?: boolean;
|
||||
conciseMethodProperty?: boolean;
|
||||
constLoop?: boolean;
|
||||
dangerousForOf?: boolean;
|
||||
dangerousTaggedTemplateString?: boolean;
|
||||
defaultParameter?: boolean;
|
||||
destructuring?: boolean;
|
||||
forOf?: boolean;
|
||||
generator?: boolean;
|
||||
letConst?: boolean;
|
||||
modules?: boolean;
|
||||
numericLiteral?: boolean;
|
||||
parameterDestructuring?: boolean;
|
||||
reservedProperties?: boolean;
|
||||
spreadRest?: boolean;
|
||||
stickyRegExp?: boolean;
|
||||
templateString?: boolean;
|
||||
unicodeRegExp?: boolean;
|
||||
};
|
||||
|
||||
// others
|
||||
namedFunctionExpressions?: boolean;
|
||||
}
|
||||
|
||||
export interface TransformOutput {
|
||||
code: string;
|
||||
map: {
|
||||
toString(): string;
|
||||
toUrl(): string;
|
||||
};
|
||||
}
|
||||
|
||||
export function transform(content: string, options?: TransformOptions): TransformOutput;
|
||||
24
types/buble/tsconfig.json
Normal file
24
types/buble/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"buble-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/buble/tslint.json
Normal file
1
types/buble/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user