Skip to content

Commit ed5ebe9

Browse files
committed
More progress, committing to get assistance with TS
1 parent a76bde5 commit ed5ebe9

File tree

8 files changed

+45
-27
lines changed

8 files changed

+45
-27
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
import axios from 'axios';
1+
import axios, {AxiosInstance} from 'axios';
22

33
// This token is set in the bootstrap.js file at the beginning of the request
44
// and is carried through from there.
55
// const token: string = '';
66

7-
const http = axios.create({
8-
'X-Requested-With': 'XMLHttpRequest',
9-
'Accept': 'application/json',
10-
'Content-Type': 'application/json',
7+
const http: AxiosInstance = axios.create({
8+
headers: {
9+
'X-Requested-With': 'XMLHttpRequest',
10+
'Accept': 'application/json',
11+
'Content-Type': 'application/json',
12+
},
1113
});
1214

1315
// If we have a phpdebugbar instance registered at this point in time go
1416
// ahead and route the response data through to it so things show up.
17+
// @ts-ignore
1518
if (typeof window.phpdebugbar !== 'undefined') {
1619
http.interceptors.response.use(response => {
20+
// @ts-ignore
1721
window.phpdebugbar.ajaxHandler.handle(response.request);
1822

1923
return response;

resources/assets/scripts/api/server/getDirectoryContents.js renamed to resources/assets/scripts/api/server/getDirectoryContents.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import http from './../http';
2-
import filter from 'lodash/filter';
3-
import isObject from 'lodash/isObject';
1+
import http from '../http';
2+
import { filter, isObject } from 'lodash';
3+
// @ts-ignore
44
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
5+
import {DirectoryContents} from "./types";
56

67
/**
78
* Get the contents of a specific directory for a given server.
8-
*
9-
* @param {String} server
10-
* @param {String} directory
11-
* @return {Promise}
129
*/
13-
export function getDirectoryContents (server, directory) {
10+
export function getDirectoryContents (server: string, directory: string): Promise<DirectoryContents> {
1411
return new Promise((resolve, reject) => {
1512
http.get(route('server.files', { server, directory }))
1613
.then((response) => {
@@ -30,7 +27,7 @@ export function getDirectoryContents (server, directory) {
3027
}
3128

3229
if (err.response.data && isObject(err.response.data.errors)) {
33-
err.response.data.errors.forEach(error => {
30+
err.response.data.errors.forEach((error: any) => {
3431
return reject(error.detail);
3532
});
3633
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type DirectoryContents = {
2+
files: Array<string>,
3+
directories: Array<string>,
4+
editable: Array<string>
5+
}

resources/assets/scripts/components/auth/Login.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
</div>
1616
</template>
1717

18-
<script>
18+
<script lang="ts">
19+
import Vue from 'vue';
1920
import Flash from '../Flash';
2021
import ForgotPassword from "./ForgotPassword";
2122
import LoginForm from "./LoginForm";
2223
import TwoFactorForm from "./TwoFactorForm";
2324
24-
export default {
25+
export default Vue.extend({
2526
name: 'login',
2627
data: function () {
2728
return {
@@ -41,5 +42,5 @@
4142
ForgotPassword,
4243
LoginForm,
4344
},
44-
}
45+
});
4546
</script>

resources/assets/scripts/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import store from './store/index';
44
const route = require('./../../../vendor/tightenco/ziggy/src/js/route').default;
55

66
// Base Vuejs Templates
7-
import Login from './components/auth/Login';
7+
import Login from './components/auth/Login.vue';
88
import Dashboard from './components/dashboard/Dashboard';
99
import Account from './components/dashboard/Account';
1010
import ResetPassword from './components/auth/ResetPassword';

storage/framework/cache/data/.gitignore

100644100755
File mode changed.

tsconfig.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
4-
"lib": [
5-
"es2015",
6-
"es2016",
7-
"dom"
8-
],
3+
"target": "esnext",
4+
"module": "esnext",
95
"strict": true,
106
"moduleResolution": "node",
11-
"module": "es2015"
7+
"lib": [
8+
"esnext",
9+
"dom",
10+
"dom.iterable",
11+
"scripthost"
12+
],
13+
"baseUrl": ".",
14+
"paths": {
15+
"@/*": [
16+
"resources/*"
17+
]
18+
}
1219
},
1320
"include": [
14-
"./resources/assets/scripts/**/*"
21+
"./resources/assets/**/*.ts",
22+
"./resources/assets/**/*.vue"
23+
],
24+
"exclude": [
25+
"node_modules"
1526
]
1627
}

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
loader: 'vue-loader',
8989
},
9090
{
91-
test: /\.tsx?$/,
91+
test: /\.ts$/,
9292
loader: 'ts-loader',
9393
exclude: /node_modules/,
9494
options: {

0 commit comments

Comments
 (0)