Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/signpostmarv/typescript-types-test
typescript @types test with tsc & gulp-typescript
https://github.com/signpostmarv/typescript-types-test
Last synced: about 1 month ago
JSON representation
typescript @types test with tsc & gulp-typescript
- Host: GitHub
- URL: https://github.com/signpostmarv/typescript-types-test
- Owner: SignpostMarv
- License: mit
- Created: 2019-08-19T17:52:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T08:06:09.000Z (about 2 years ago)
- Last Synced: 2024-05-02T01:15:25.495Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 276 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Typescripts Types Test
using requestIdleCallback in typescript requires using [@types/requestidlecallback](https://www.npmjs.com/package/@types/requestidlecallback)# Example
```ts
import {requestIdleCallback} from "requestidlecallback";export async function Test() : Promise {
return new Promise((yup) => {
requestIdleCallback(() => {
alert('done');yup();
});
});
}
```## npm run build
```js
import { requestIdleCallback } from "requestidlecallback";
export async function Test() {
return new Promise((yup) => {
requestIdleCallback(() => {
alert('done');
yup();
});
});
}
```## gulp
```js
export async function Test() {
return new Promise((yup) => {
requestIdleCallback(() => {
alert('done');
yup();
});
});
}//# sourceMappingURL=test.module.js.map
```### gulpfile.js
[gulp-replace](https://www.npmjs.com/package/gulp-replace) is used mostly to
strip out the import statement, but also to force typescript to behave and
use tabs instead of spaces (input tabs, you output spaces for some reason), as
per discussion on [twitter](https://mobile.twitter.com/sarah_federman/status/1146544481556033537) &
[reddit](https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/) regarding the accessibility
impact of tabs & spaces.```js
const gulp = require('gulp');
const typescript = require('gulp-typescript');
const replace = require('gulp-replace');
const sourcemaps = require('gulp-sourcemaps');gulp.task('default', () => {
return gulp.src(
'./ts/**/*.module.ts'
).pipe(
sourcemaps.init()
).pipe(
typescript.createProject('./tsconfig.json')()
).pipe(
replace(
'import { requestIdleCallback } from "requestidlecallback";\n',
''
)
).pipe(
replace(
/ {4}/g,
'\t'
)
).pipe(
sourcemaps.write('./', {
includeContent: false,
})
).pipe(
gulp.dest('./js/')
);
});
```